// 封装所有和部门相关的接口请求
import request from '@/utils/request'

export const getDepartments = () =>
  request({
    url: '/company/department'
  })

export const getManagerList = () =>
  request({
    url: '/sys/user/simple'
  })
/**
 * 用于增加子部门
 * @param {*} data 5个
 * @returns 返回这次请求
 */
export const addDepartments = data =>
  request({
    url: '/company/department',
    method: 'post',
    data
  })

// 编辑涉及两个接口
/**
 * 获取部门id获取详情
 * @param {*} id 部门id
 * @returns 返回请求
 */
export const getDepartDetail = id =>
  request({
    url: `/company/department/${id}`
  })

/**
   * 编辑部门
   * @param {*} data 编辑部门需要7个字段 id,
    pid,
    name,
    code,
    managerId,
    introduce,
    createTime
   * @returns 返回请求
   */
export const editDepartments = data =>
  request({
    url: `/company/department/${data.id}`,
    method: 'put',
    data
  // {
    // id,
    // pid,
    // name,
    // code,
    // managerId,
    // introduce,
    // createTime
  // }
  })

/**
   * 删除部门
   * @param {*} id 部门id
   * @returns 返回这个请求
   */
export const deleteDepartment = id =>
  request({
    url: `/company/department/${id}`,
    method: 'delete'
  })
